﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:il="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions" 
    xmlns:local="clr-namespace:HugeFlow"
    xmlns:HugeFlow_CommandPattern_Interactivity="clr-namespace:HugeFlow.CommandPattern.Interactivity;assembly=HugeFlow.CommandPattern" x:Class="HugeFlow.ImageSearchPanel"
    Width="300" Height="400">
    <UserControl.DataContext>
        <local:ImageSearchPanelViewModel />
    </UserControl.DataContext>
	<i:Interaction.Behaviors>
		<il:MouseDragElementBehavior/>
	</i:Interaction.Behaviors>
    <Grid x:Name="LayoutRoot">

    	<Grid.RowDefinitions>
    		<RowDefinition Height="30"/>
    		<RowDefinition Height="40"/>
    		<RowDefinition Height="*"/>
    	</Grid.RowDefinitions>
    	<i:Interaction.Behaviors>
    		<HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior x:Name="SearchImage" Command="{Binding SearchImageCommand, Mode=OneWay}" CommandParameter="{Binding Text, ElementName=textBox, Mode=OneWay}">
    			<i:Interaction.Triggers>
    				<HugeFlow_CommandPattern_Interactivity:KeyTrigger SourceName="textBox" FiredOn="KeyUp" Key="Enter">
    					<i:InvokeCommandAction CommandName="CommandTriggers"/>
    				</HugeFlow_CommandPattern_Interactivity:KeyTrigger>
    				<i:EventTrigger SourceName="button" EventName="Click">
    					<i:InvokeCommandAction CommandName="CommandTriggers"/>
    				</i:EventTrigger>
    			</i:Interaction.Triggers>
    		</HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior>
    		<HugeFlow_CommandPattern_Interactivity:ExecuteStaticCommandBehavior x:Name="ShowLargeImage" CommandName="ShowLargeImage" CommandParameter="{Binding SelectedItem, ElementName=listBox, Mode=OneWay}">
    			<i:Interaction.Triggers>
    				<i:EventTrigger SourceName="listBox" EventName="SelectionChanged">
    					<i:InvokeCommandAction CommandName="CommandTriggers"/>
    				</i:EventTrigger>
    			</i:Interaction.Triggers>
    		</HugeFlow_CommandPattern_Interactivity:ExecuteStaticCommandBehavior>
    		<HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior x:Name="GetRecentImage" Command="{Binding GetRecentImageCommand, Mode=OneWay}">
    			<i:Interaction.Triggers>
    				<HugeFlow_CommandPattern_Interactivity:LoadedEventTrigger SourceName="LayoutRoot">
    					<i:InvokeCommandAction CommandName="CommandTriggers"/>
    				</HugeFlow_CommandPattern_Interactivity:LoadedEventTrigger>
    			</i:Interaction.Triggers>
    		</HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior>
    	</i:Interaction.Behaviors>
    	<Rectangle Fill="White" Stroke="#7FD0D0D0" RadiusX="10" RadiusY="10" Grid.RowSpan="3">
    		<Rectangle.Effect>
    			<DropShadowEffect/>
    		</Rectangle.Effect>
    	</Rectangle>
    	<TextBlock Margin="10,0,194,2" FontFamily="Arial" FontSize="16" Text="Search" TextWrapping="Wrap" Foreground="#FF0075FF" VerticalAlignment="Bottom"/>
    	<TextBox x:Name="textBox" Margin="10,8,80,8" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Keyword, Mode=TwoWay, UpdateSourceTrigger=Explicit}"/>
    	<Button x:Name="button" HorizontalAlignment="Right" Margin="0,8,10,8" Width="68" Grid.Row="1" Content="Search"/>
    	<StackPanel HorizontalAlignment="Right" Margin="0,0,10,4" Width="40" Height="20" Orientation="Horizontal" VerticalAlignment="Bottom">
    		<Ellipse Fill="#FF0063DC" Stroke="Black" StrokeThickness="0" Margin="0" Width="20" Height="20"/>
    		<Ellipse Fill="#FFFF0084" Stroke="Black" StrokeThickness="0" Height="20" Margin="0" Width="20"/>
    	</StackPanel>
    	<ListBox x:Name="listBox" Margin="10" Grid.Row="2" ItemContainerStyle="{StaticResource ListBoxItemStyle2}" Style="{StaticResource ListBoxStyle1}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding Items, Mode=OneWay}"/>

    </Grid>
</UserControl>
